package com.example.module_orders.vm

import androidx.lifecycle.MutableLiveData
import com.yuwei.base.BaseViewModel
import com.yuwei.http.ApiService
import com.yuwei.http.entity.AddOrdersBody
import com.yuwei.http.entity.AddOrdersEntity
import com.yuwei.http.entity.ordersEntity
import com.yuwei.http.entity.ordersEntityItem
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
@HiltViewModel
class OrdersViewModel @Inject constructor(
    val apiService: ApiService
):BaseViewModel() {
    val ordersSuccess by lazy { MutableLiveData<ordersEntity>() }
    fun getOrdersList(){
        executeNetwork({
          apiService.getOrders()
        },ordersSuccess::postValue)
    }
    //添加数据
    val addOrderSuccess by lazy { MutableLiveData<AddOrdersEntity>() }
    fun getAddOrder(addOrdersBody: AddOrdersBody){
        executeNetwork({
            apiService.getAddOrders(addOrdersBody)
        },addOrderSuccess::postValue)
    }
    //删除数据
    val deleteSuccess by lazy { MutableLiveData<String>() }
    fun getDeleteOrders(id:Int){
        executeNetwork({
            apiService.getDeleteOrders(id)
        },deleteSuccess::postValue)
    }
}